package com.itheima.day06.mySimpleDateFormat.test2;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");

        System.out.println("活动开放，开放时间为5秒钟");
        Date dateStart = new Date();
        long startTime = dateStart.getTime();
        System.out.println("当前时间为：" + sdf.format(dateStart));


        Date dateEnd = new Date(startTime + 5 * 1000);
        long endTime = dateEnd.getTime();
        System.out.println("结束时间为：" + sdf.format(endTime));
        // System.out.println(endTime - startTime);

        long usetTime = -1L;

        System.out.println("下单请按Y/y,放弃这次机会请按任意键");
        String userInput = sc.nextLine();
        if ("y".equals(userInput) || "Y".equals(userInput)) {
            Date dateUser = new Date();
            usetTime = dateUser.getTime();
        } else {
            System.out.println("谢谢，再见");
            System.exit(0);
        }


        if (usetTime <= endTime && usetTime >= startTime) {
            System.out.println("恭喜恭喜，成功上当，欢迎下次再来。");
        } else {
            System.out.println("我无话可说");
        }

    }
}
